<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>LOGIN SCREEN</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
    <script>
        $(document).ready(function () {
            $('#loginForm').submit(function (event) {
                event.preventDefault();

                var username = $('#username').val();
                var password = $('#password').val();

                $.ajax({
                    url: `/wsn/login`,
                    type: 'POST',
                    data: {username: username, password: password},
                    success: function (response) {
                        alert(response); // 在这里处理登录成功后的响应，例如重定向到新页面
                    },
                    error: function (xhr, status, error) {
                        alert(xhr.responseText); // 在这里处理登录失败后的响应，例如显示错误消息
                    }
                });
            });
        });

    </script>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        .loginForm {
            margin: 80px auto;
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
        }

        .box1 {

            width: 1000px;
            height: 50px;
            background-color: #ededed;
            border-style: solid;
            border-width: 1px 1px 0px 1px;
            border-color: black;
        }

        .box1 p {
            display: inline-block;
            font-size: 15px;
            margin: 15px 30px;
        }

        .box1 input {
            display: inline-block;
            position: relative;
            left: 760px;
        }

        .box2 {
            width: 1000px;
            height: 500px;
            border-style: solid;
            border-width: 0px 1px 1px 1px;
            border-color: black;
        }

        .box2 img {
            width: 300px;
            height: 150px;
            position: relative;
            left: 350px;
            top: 10px;
        }

        .box3 {
            margin: 30px auto;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .box3 input {
            width: 400px;
            height: 60px;
            font-size: 20px;
        }

        .box4 {
            margin-left: 16px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .box4 input {
            width: 400px;
            height: 60px;
            font-size: 20px;
        }

        .box5 {
            margin: 40px auto;
            display: flex;
            justify-content: center;
        }

        .box5 input {
            width: 160px;
            height: 40px;
            background-color: #fff;
            border: 1px solid;
            display: block;
            margin-left: 60px;
        }
    </style>
</head>

<body>
<form id="loginForm">
    <div class="loginForm">
        <div class="box1">
            <p>WS健身管理系统-登录</p>
            <input type="button" name="close" value="X" onclick="window.close();" />
        </div>
        <div class="box2">
            <img src="../Large_Logo.png" alt="Logo">
            <div class="box3">
                <span>用户名：</span><input type="text" name="username" id="username">
            </div>
            <div class="box4">
                <span>密码：</span><input type="password" name="password" id="password">
            </div>
            <div class="box5">

                    <input type="submit" name="submit" value="登录">

                <input type="button" name="close" value="退出" onclick="window.close();" />
            </div>
        </div>
    </div>
</form>
</body>

</html>